//
//  ViewController.m
//  EnumerateDemo
//
//  Created by Alphts on 2017/6/12.
//  Copyright © 2017年 iflytek. All rights reserved.
//

#import "ViewController.h"
#import "NSMutableArray+Helper.h"

@interface ViewController ()
@property (nonatomic, strong) NSMutableArray *mArray;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.mArray = [NSMutableArray array];
//    NSArray *array = @[@"1",@"2",@[@"3",@"4"],@"5",@[@"6",@"7",@"8"]];

    NSArray *items = @[@"1",@"2",@[@"3",@"4"],@"5",@[@"6",@"7",@"8"]];
    
    [self dealWithArray:items];
    
//    NSMutableArray *mutableItems = [NSMutableArray arrayWithArray:items];
//    id<Iterator> iterator = [mutableItems iterator];
//    while ([iterator hasNext]) {
//        NSObject *obj = [iterator next];
//        if ([obj isKindOfClass:[NSArray class]]) {
//            NSLog(@"objectValue=%@",obj);
////            [iterator remove];
//        }
//    }
//    NSLog(@"mutableItems=%@",mutableItems);
    
//    
//    NSEnumerator *itemenumrator = [array objectEnumerator];
//    id item;
//    while (item = [itemenumrator nextObject]) {
//        if ([item isKindOfClass:[NSArray class]]) {
//            NSLog(@"==");
//        }
//        NSLog(@"item is %@",[item class]);
//    }
   
}

- (void)dealWithArray:(NSArray *)array{
    
//    NSArray *items = @[@"1",@"2",@[@"3",@"4"],@"5",@[@"6",@"7",@"8"]];
    
    NSMutableArray *mutableItems = [NSMutableArray arrayWithArray:array];
    id<Iterator> iterator = [mutableItems iterator];
    while ([iterator hasNext]) {
        NSObject *obj = [iterator next];
        if ([obj isKindOfClass:[NSArray class]]) {
            NSLog(@"objectValue=%@",obj);
            NSArray *array = (NSArray *)obj;
            [self dealWithArray:array];
        }else{
            [self.mArray addObject:obj];
        }
    }
    NSLog(@"self.mArray=%@",self.mArray);
    
}


@end






